package com.hyst.apicontroller.demo;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.hyst.repository.ExamineRecord_Repository;
import com.hyst.repository.Person_CV_Repository;
import com.hyst.repository.Person_Produce_Plan_Repository;
import com.hyst.repository.Person_Produce_Plan_Trend_Repository;
import com.hyst.repository.Person_Produce_Real_Repository;
import com.hyst.repository.Person_Produce_Real_Trend_Repository;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;

@Api(value = "UserAnalysis", description = "人员分析相关")
@RestController
@RequestMapping(value = "users/analysis") // 通过这里配置使下面的映射都在/users下，可去除
public class UserAnalysisController {

	@Autowired
	Person_CV_Repository person_CV_Repository;
	@Autowired
	Person_Produce_Plan_Repository person_Produce_Plan_Repository;
	@Autowired
	Person_Produce_Real_Repository person_Produce_Real_Repository;
	@Autowired
	Person_Produce_Plan_Trend_Repository person_Produce_Plan_Trend_Repository;
	@Autowired
	Person_Produce_Real_Trend_Repository person_Produce_Real_Trend_Repository;
	@Autowired
	ExamineRecord_Repository examineRecord_Repository;

	@ApiOperation(value = "获取个人参与过的项目")
	@GetMapping("getProductsByAccount/{uniqueid}")
	public List getProductsByAccount(@PathVariable @ApiParam(value = "用户唯一id", required = true) String uniqueid) {
		List list = person_CV_Repository.findCVByUniqueid(uniqueid);
		return list;
	}

	@ApiOperation(value = "获取个人车间级工作计划")
	@GetMapping("getPlans/{userid}/{starttime}/{endtime}")
	public List getPlans(@PathVariable @ApiParam(value = "用户唯一id", required = true) String userid,
			@PathVariable @ApiParam(value = "开始时间", required = true) String starttime,
			@PathVariable @ApiParam(value = "结束时间", required = true) String endtime) {
		List list = person_Produce_Plan_Repository.findAllByUserID(userid, starttime, endtime);
		return list;
	}
	
	@ApiOperation(value = "获取个人任务趋势图")
	@GetMapping("getTasksTend/{userid}/{starttime}/{endtime}")
	public List getTasksTend(@PathVariable @ApiParam(value = "用户唯一id", required = true) String userid,
			@PathVariable @ApiParam(value = "开始时间", required = true) String starttime,
			@PathVariable @ApiParam(value = "结束时间", required = true) String endtime) {
		List list = person_Produce_Plan_Trend_Repository.findAllByUserID(userid, starttime, endtime);
		return list;
	}
	
	@ApiOperation(value = "获取个人实际生产记录")
	@GetMapping("getRealProduce/{userid}/{starttime}/{endtime}")
	public List getRealProduce(@PathVariable @ApiParam(value = "用户唯一id", required = true) String userid,
			@PathVariable @ApiParam(value = "开始时间", required = true) String starttime,
			@PathVariable @ApiParam(value = "结束时间", required = true) String endtime) {
		List list = person_Produce_Real_Repository.findAllByUserId(userid, starttime, endtime);
		return list;
	}
	
	@ApiOperation(value = "获取个人实际生产趋势图")
	@GetMapping("getRealTasksTend/{userid}/{starttime}/{endtime}")
	public List getRealTasksTend(@PathVariable @ApiParam(value = "用户唯一id", required = true) String userid,
			@PathVariable @ApiParam(value = "开始时间", required = true) String starttime,
			@PathVariable @ApiParam(value = "结束时间", required = true) String endtime) {
		List list = person_Produce_Real_Trend_Repository.findAllByUserID(userid, starttime, endtime);
		return list;
	}
	
	@ApiOperation(value = "获取个人送检汇总情况")
	@GetMapping("getOutPutTotal/{userid}/{starttime}/{endtime}")
	public List getOutPutTotal(@PathVariable @ApiParam(value = "用户唯一id", required = true) String userid,
			@PathVariable @ApiParam(value = "开始时间", required = true) String starttime,
			@PathVariable @ApiParam(value = "结束时间", required = true) String endtime) {
		List list = examineRecord_Repository.findAllByUserID(userid, starttime, endtime);
		return list;
	}
	

}
